package myservlet;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import dao.newsDAO;

import bean.News;
import bean.NewsForm;

@Controller
public class newsController {

	private newsDAO newsDao;

	/*
	 * @RequestMapping(value = "/trangchu", method = RequestMethod.GET) public
	 * ModelAndView Homepage() { return new ModelAndView("index.html",
	 * "command", new News()); }
	 */
	@RequestMapping(value = "/showNewsContent.do", method = RequestMethod.GET)
	public String showNewsContent(@ModelAttribute("News") NewsForm newsform,
			Map<String, Object> model) {
		System.out.println("before try");

		try {
			System.out.println("before DAO");
			newsform = (NewsForm) newsDao.selectAllSocialNews();
			System.out.println(newsform.toString());
			model.put("list", newsform);
		} catch (RuntimeException e) {
			e.printStackTrace();
		}
		return "result";

	}

}
